package ua.kpi_java_training.tyshchenko.module2.test;

import static junit.framework.Assert.*;
import org.junit.Before;
import org.junit.Test;
import ua.kpi_java_training.tyshchenko.module2.RandomNumber;

/**
 * @author Vlad Tyshchenko
 * @version 1.0 5 June 2013
 */
public class RandomNumberTest {
    int testNumber1, testNumber2;
    RandomNumber rand;

    @Before
    public void setUp() {
        testNumber1 = 5;
        testNumber2 = 3;
        rand = new RandomNumber();
    }

    @Test
    public void testGetDirection() {
        for (int i = 0; i < 1000; i++) {
            assertTrue("test getDirection ", rand.getDirection(4) >= 0 && rand.getDirection(4) <= 3);
            assertFalse("test getDirection ", rand.getDirection(4) < 0 && rand.getDirection(4) > 3);
        }
    }

    @Test
    public void testGetStep() {
        for (int i = 0; i < 1000; i++) {
            assertTrue("test getStep ", rand.getStep(testNumber1) >= 1 && rand.getStep(testNumber1) <= testNumber1);
            assertFalse("test getStep ", rand.getStep(testNumber1) < 1 && rand.getStep(testNumber1) > testNumber1);
            assertTrue("test getStep ", rand.getStep(testNumber2) >= 1 && rand.getStep(testNumber2) <= testNumber2);
            assertFalse("test getStep ", rand.getStep(testNumber2) < 1 && rand.getStep(testNumber2) > testNumber2);
        }
    }

    @Test
    public void testGetPosition() {
        for (int i = 0; i < 1000; i++) {
            assertTrue("test hetPosition ",
                    rand.getPosition(testNumber1) >= 0 && rand.getPosition(testNumber1) <= testNumber1 - 1);
            assertFalse("test hetPosition ",
                    rand.getPosition(testNumber1) < 0 && rand.getPosition(testNumber1) > testNumber1 - 1);
            assertTrue("test hetPosition ",
                    rand.getPosition(testNumber2) >= 0 && rand.getPosition(testNumber2) <= testNumber2 - 1);
            assertFalse("test hetPosition ",
                    rand.getPosition(testNumber2) < 0 && rand.getPosition(testNumber2) > testNumber2 - 1);
        }
    }
}
